#ifndef __MY_AUTO_DEFER_H__
#define __MY_AUTO_DEFER_H__

#include "defines.h"
#include <functional>

class AutoDefer {
private:
	using defer_func = std::function<void()>;

private:
	defer_func func_ = nullptr;

public:
	AutoDefer(defer_func func) : func_(func) { }
	~AutoDefer() { if (func_) func_(); }
};

#endif // __MY_AUTO_DEFER_H__